package com.xiaofu.sort;

import com.xiaofu.sort.bubble.BubbleSort3;
import com.xiaofu.sort.count.CountingSort;
import com.xiaofu.sort.heap.HeapSort;
import com.xiaofu.sort.insertion.InsertionSort;
import com.xiaofu.sort.merge.MergeSort;
import com.xiaofu.sort.quick.QuickSort;
import com.xiaofu.sort.radix.RadixSort;
import com.xiaofu.sort.selection.SelectionSort;
import com.xiaofu.sort.shell.ShellSort;
import com.xiaofu.sort.tools.Integers;

import java.util.Arrays;

/**
 * @author: xiaofu
 * @DESCRIPTION: a technology seeker
 * @date: 2021-08-01 22:56
 */
public class Main {

    public static void main(String[] args) {
        Integer[] array = Integers.random(100000, 1, 50000);

        testSorts(array,
                new BubbleSort3(),
                new HeapSort(),
                new SelectionSort(),
                new MergeSort(),
                new InsertionSort(),
                new QuickSort(),
                new ShellSort(),
                new CountingSort(),
                new RadixSort()
        );

    }

    private static void testSorts(Integer[] array, Sort... sorts) {
        for (Sort sort : sorts) {
            Integer[] copy = Integers.copy(array);
            sort.sort(copy);
            System.out.println(Integers.isAscOrder(copy));
        }
        Arrays.sort(sorts);
        for (Sort sort : sorts) {
            System.out.println(sort);
        }
    }

}
